//標準類型
var num = 2;   //變數賦值為2,此時num被自動推斷為number類型
function numFunc(n:number){
    return n*n;
}
numFunc(num);  //編譯正常
//自訂類型
var p = new People('One') //p自動推斷為People類型
console.log(p.name);
var l = [1, 'hello', false, null];
//l會被推斷成(number | string | boolean | null)[]的聯合類型陣列
var l2:(number | string | boolean | null)[] = l;
funciton cp(p:string | number): string | number{
    if(typeof p === 'number'){
        return p + p;
    }else {
        return p + p;
    }
}
console.log(cp(3));   //6
console.log(cp('Hello'))   //HelloHello
interface Shape {
    area(): number
}
interface Color {
    color: string
}
class RedCircle implements Shapr, Color{
    radius: number
    color = 'red'
    constructor(radius:number) {
        this.radius = radius;
    }
    area(): number {
        return this.radius * this.radius * 3.14;
    }
}
var c:shape & Color = new RedCircle(2);
console.log(c.color, c.area());
今天的內容就到這邊為止,明天將會介紹TypeScript的類型區分能力及其他更多內容。